<?php
include_once('common/header.php');
if($AppUI->id <=0 || (isset($_SESSION['search']) && ($_SESSION['search'] <= 0))) {
	$this->_redirect(HOST_BACKEND);
}
$objSearch 		= new Ecore_Search();
$objEducation	= new Education();

$intStatus		= -1;
$intOption		= 0;
$strKey			= '';
$strStart		= '';
$strEnd			= '';
$intCategoryId	= 0;
$intProvince	= 0;
$intDistrict	= 0;
$intPage		= $objRequest->getParam('page', 1);
$intLimit		= $variable['ADMIN_LIMIT']['val'];
$intOff			= (($intPage-1) * $intLimit);
$arrResult		= $objEducation->getAll($AppUI->type, $intCategoryId, $intType, $intStatus, $intOption, 
										$strKey, Ecore_Function::convertStrToDate($strStart), Ecore_Function::convertStrToDate($strEnd), $intOff, $intLimit, 
										$intProvince, $intDistrict, $intTotal);
if(isset($arrResult)) {
	foreach($arrResult as $val) {
		$strFullAddr	= $val['addr'] . ', ' . $val['district_name'] . ', ' . $val['province_name'];		
		$strSlug		= Ecore_Rewrite_Education::slug($val['educateid'],$val['name_se']);
		$objSearch->addUpdate($val['educateid'], $val['type'], $val['name'], $strFullAddr, $val['tag'],
							  $val['short'], $val['image'], $strSlug, $val['longitude'], $val['latitude'],
							  Ecore_Function::now(), $val['status'], 3, $val['categoryid'], '',
							  $val['district'], $val['province'], $val['country'], $val['userid']);
	}
	Ecore_Function::setMsg('Convert dữ liệu Trường học thành công!');
} else {
	Ecore_Function::setError('Không có dữ liệu để convert.');
}
$this->_redirect(isset($_SESSION[SESSION_BACKURL]) ? $_SESSION[SESSION_BACKURL] : HOST_BACKEND);